package com.yanqu.road.entity.activity.sonhai.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_activity_son_hai_user_data")
public class SonHaiServerUserData extends DataObject {

    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "玩家ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "触发礼包MAP")
    private Map<Integer, SonHaiUserMallData> mallDataMap = new ConcurrentHashMap<>();

    public SonHaiServerUserData() {
    }

    public SonHaiServerUserData(int activityId, long userId) {
        this.activityId = activityId;
        this.userId = userId;
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }
    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }
    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public Map<Integer, SonHaiUserMallData> getMallDataMap() {
        return mallDataMap;
    }
    public void setMallDataMap(Map<Integer, SonHaiUserMallData> mallDataMap) {
        if (null == mallDataMap){
            return;
        }
        if (this.mallDataMap == null || !this.mallDataMap.equals(mallDataMap)) {
            this.mallDataMap = mallDataMap;
            setOp(DataStatus.Update);
        }
    }

    public void addMallData(SonHaiUserMallData mallData){
        if (mallData == null){
            return;
        }
        this.mallDataMap.put(mallData.getMallId(), mallData);
        setOp(DataStatus.Update);
    }

}
